<?php

$html_h = file_get_contents('http://www.douyutv.com/');
if (preg_match_all('/title="([^"]*)"[^-]*-original="(http:\/\/staticlive\.douyutv\.com\/upload\/web_pic\/\d\/(\d*)_\d*_thumb\.jpg)/', $html_h, $m)) {
	foreach ($m[0] as $c_l) {
		if (preg_match('/title="([^"]*)"[^-]*-original="(http:\/\/staticlive\.douyutv\.com\/upload\/web_pic\/\d\/(\d*)_\d*_thumb\.jpg)/', $c_l, $m_1)) {
			$dys[] = array($m_1[1], $m_1[2], $m_1[3]);
		}
	} 
}
$html_h = file_get_contents('http://www.huya.com/');
if (preg_match_all('/"channel":"[^"]*","liveChannel":"[^"]*","introduction":"[^"]*"/', $html_h, $m)) {
	foreach ($m[0] as $c_l) {
		if (preg_match('/"channel":"[^"]*","liveChannel":"[^"]*","introduction":"[^"]*"/', $c_l, $m_1)) {
			$huyas[] = json_decode('{'.$m_1[0].'}');
		}
	} 
}
$html_h = file_get_contents('http://m.yy.com/');
if (preg_match('/"list":"(\[([^\]]*\][^"])*[^\]]*\])"/', $html_h, $m)) {
	$yys = json_decode(stripcslashes($m[1]));
}
?>
<script src="forum/inc/forum.js"></script>
<link rel="stylesheet" href="forum/inc/forum.css">
<?php require_once('forum/inc/pub_h.phtml') ?>
<audio id="q_audio" src="forum/inc/notify.mp3" autoplay style="display:none"></audio>
<div class="container-fluid websocket">
	<div class="row clearfix">
		<div class="col-md-8 column hidden-xs hidden-sm">
			<embedc><embed width="100%" height="610" src="http://player.hz.letv.com/live.swf" quality="high" align="middle" play="true" loop="true" scale="noscale" wmode="opaque" devicefont="false" bgcolor="#000000" menu="true" allowscriptaccess="always" allowfullscreen="true" salign="TL" flashvars="streamid=ws_hunanwsHD_1800&amp;cid=4&amp;gslb=http://live.gslb.letv.com/&amp;autoplay=true&amp;rate=800&amp;typeFrom=letv_live_hao123live&amp;ark=100&amp;cid=4&amp;ch=letv_live_sports_ws_hunanwsHD_1800_1800&amp;usewhitelist=0"></embedc>
			<embedc><embed style="margin-bottom:-4px" width="100%" height="610" src="http://www.iqiyi.com/common/flashplayer/20150215/LivePlayer_3_0_3_9.7.swf" allowfullscreen="true" allowscriptaccess="always" bgcolor="#000000" wmode="Opaque" flashvars="coreUrl=http://www.iqiyi.com/common/flashplayer/20150215/20324.swf&preLoaderUrl=http://www.iqiyi.com/player/20130709174613/loading.swf&vid=c22_ct_hnetv1_js_smooth_s10&cid=c_100001_10024&stationType=pps&local=1&tvId=local&duration=14400"></embedc>
			<embedc><embed style="margin-bottom:-4px" width="100%" height="610" src="http://www.iqiyi.com/common/flashplayer/20150215/LivePlayer_3_0_3_9.7.swf" allowfullscreen="true" allowscriptaccess="always" bgcolor="#000000" wmode="Opaque" flashvars="coreUrl=http://www.iqiyi.com/common/flashplayer/20150215/20324.swf&amp;preLoaderUrl=http://www.iqiyi.com/player/20130709174613/loading.swf&amp;vid=c23_ct_hunantv3_yl_smooth_s10&amp;cid=c_100001_10024&amp;stationType=pps&amp;local=1&amp;tvId=local&amp;duration=14400"></embedc>
			<embedc><embed style="margin-bottom:-4px" width="100%" height="610" src="http://www.iqiyi.com/common/flashplayer/20150215/LivePlayer_3_0_3_9.7.swf" allowfullscreen="true" allowscriptaccess="always" bgcolor="#000000" wmode="Opaque" flashvars="coreUrl=http://www.iqiyi.com/common/flashplayer/20150215/20324.swf&preLoaderUrl=http://www.iqiyi.com/player/20130709174613/loading.swf&vid=c7_ct_hunantv4_dsj_smooth_s10&cid=c_100001_10024&stationType=pps&local=1&tvId=local&duration=14400"></embedc>
			<embedc id="dy"><iframe style="margin-bottom:-4px" src="" height="610" width="100%" frameborder="0"></iframe></embedc>
			<embedc><embed style="margin-bottom:-5px" src="" quality="high" width="100%" height="610" allownetworking="internal" allowscriptaccess="never" allowfullscreen="true"></embedc>
		</div>
		<div class="col-md-4 column">
			<h3>HIICI 娱乐间
				<div class="btn-group">
					<a class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-expanded="false">HIICI</a>
					<ul class="dropdown-menu" role="menu">
						<li><a target="_blank" href="?c=websocket&a=agreement">我要HIICI直播 <span class="glyphicon glyphicon-hd-video" aria-hidden="true"></span></a></li>
						<li class="divider"></li>
						<li><a href="javascript:chn_chg(0, '0')">湖南卫视</a></li>
						<li class="divider"></li>
						<li><a href="javascript:chn_chg(1, '0')">湖南经视</a></li>
						<li class="divider"></li>
						<li><a href="javascript:chn_chg(2, '0')">湖南娱乐</a></li>
						<li class="divider"></li>
						<li><a href="javascript:chn_chg(3, '0')">湖南电视剧</a></li>
						<?php foreach ($dys as $dy) { ?>
						<li class="divider"></li>
						<li><a href="javascript:chn_chg(4, '<?php echo $dy[2] ?>')"><img src="<?php echo $dy[1] ?>"/><?php echo $dy[0] ?></a></li>
						<?php } ?>
						<?php foreach ($huyas as $huya) { ?>
						<li class="divider"></li>
						<li><a href="javascript:chn_chg(5, '<?php echo $huya->channel.'/'.$huya->liveChannel ?>')"><?php echo $huya->introduction ?></a></li>
						<?php } ?>
						<?php foreach ($yys as $yy) { ?>
						<li class="divider"></li>
						<li><a href="javascript:chn_chg(5, '<?php echo $yy->subCid.'/'.$yy->subCid ?>')"><?php echo $yy->nick ?></a></li>
						<?php } ?>
					</ul>
				</div>
			</h3>  
			<div class="c_cont">
				<div id="log"></div>  
			</div>
			<form class="form-inline" action="javascript:send()">
				<input id="msg" type="textbox" class="form-control"/>  
				<button class="btn btn-default">发送</button>  
			</form>
		</div>
	</div>
</div>
<script>  
var socket, user = 0;  
<?php require_once('websocket/token.php') ?>  

chn_chg_e(1);

function init(){  
	socket = new WebSocket('ws://hiici.com:81');  
	socket.onopen    = function(msg){ log('欢迎进入 HIICI 直播间！(当前 '+count+' 人在线)'); socket.send('{"token":"'+token+'","u_id":"'+user.id+'","u_name":"'+user.name+'"}'); };  
	socket.onmessage = function(msg){ log('<a target="_blank" href="?c=center&a=index&user_id='+msg.data); };  

	$('li#websocket').addClass('active');
}  

function send(){  
	if (!user) jump_to_login('?c=websocket&a=websocket_ui'); 
	var msg = $('#msg').val();  
	if (!msg) return false;  

	$('#msg').val('');  
	socket.send(msg);  
}  
function chn_chg(i, h_id) {  
	$('embedc').hide(); $('embedc:eq(0)').show();  $('embedc:eq(0)').hide();  

	$('embedc#dy iframe').attr('src', 'http://staticlive.douyutv.com/common/share/play.swf?room_id='+h_id);  
	$('embedc:last embed').attr('src', 'http://yy.com/s/'+h_id+'/yyscene.swf');  

	$('embedc:eq('+i+')').show();  
	$('.websocket a.dropdown-toggle').html($('.websocket a[href="javascript:chn_chg('+i+', '+"'"+h_id+"'"+')"]').html().replace(/<\/?[^>]*>/g,''));  
}  

var save_i = 0, cur_i = 0;
function chn_chg_e(i) {  
	eval($('.websocket li:not(.divider):eq('+i+') a').attr('href'))
}
function onkey(e){  
	if (38 == e.keyCode) chn_chg_e(save_i);  
	if (40 == e.keyCode) { save_i = cur_i; cur_i = Math.floor(Math.random()*( $('.websocket li:not(.divider) a').length+1)); chn_chg_e(cur_i); }
}  
</script>  
	<body onload="init()" onkeydown="onkey(event)"></body>  
